package com.itxx.udp.Unicast.udpDemo1;

import java.io.IOException;
import java.net.*;

public class Send1 {
    public static void main(String[] args) throws IOException {
        //创建datagramSocket对象
        DatagramSocket ds= new DatagramSocket();
        //将要发送的数据装进报包
        String s= "hello";
        byte[] bytes = s.getBytes();
        InetAddress byName = InetAddress.getLocalHost();
        int port = 54321;
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, byName, port);
        //发送
        ds.send(dp);
        //释放资源
        ds.close();
    }
}
